import dayjs from 'dayjs'
import { translate } from '@/utils/i18n'
export const pickerOptions = {
  disabledDate(time) {
    return time.getTime() < new Date(new Date().toLocaleDateString()).getTime()
  },
  shortcuts: [
    {
      text: translate('jin7'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 6)
        picker.$emit('pick', [start, end])
      }
    },
    {
      text: translate('jin30'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 29)
        picker.$emit('pick', [start, end])
      }
    },
    {
      text: translate('jin60'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 59)
        picker.$emit('pick', [start, end])
      }
    },
    {
      text: translate('jin90'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 89)
        picker.$emit('pick', [start, end])
      }
    }
  ]
}

export const pickerOptionsS = { // 精确到秒
  disabledDate(time) {
    return time.getTime() < new Date(new Date().toLocaleDateString()).getTime()
  },
  shortcuts: [
    {
      text: translate('jin7'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 7)
        picker.$emit('pick', [start, end])
      }
    },
    {
      text: translate('jin30'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 30)
        picker.$emit('pick', [start, end])
      }
    },
    {
      text: translate('jin60'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 60)
        picker.$emit('pick', [start, end])
      }
    },
    {
      text: translate('jin90'),
      onClick(picker) {
        const end = new Date()
        const start = new Date()
        end.setTime(start.getTime() + 3600 * 1000 * 24 * 90)
        picker.$emit('pick', [start, end])
      }
    }
  ]
}

export const pickerOptionsStatic = {
  shortcuts: [{
    text: translate('jin7'),
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(end.getTime())
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
      picker.$emit('pick', [start, end])
    }
  },
  {
    text: translate('jin30'),
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(end.getTime())
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 29)
      picker.$emit('pick', [start, end])
    }
  },
  {
    text: translate('jin60'),
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(end.getTime())
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 59)
      picker.$emit('pick', [start, end])
    }
  },
  {
    text: translate('jin90'),
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      end.setTime(end.getTime())
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 89)
      picker.$emit('pick', [start, end])
    }
  }],
  disabledDate(time) {
    // var curDate = new Date(new Date().toLocaleDateString()).getTime()
    const date = dayjs(new Date()).format('YYYY-MM-DD') + ' 23:59:59'
    var preDate = new Date(date).getTime()
    return time.getTime() > preDate
  }
}

export const seckillTypeOptions = [
  { label: translate('combo'), value: '04' },
  { label: translate('kc'), value: '07' },
  { label: translate('zxk'), value: '19' }
]
export const pickerOptionsDis = {
  disabledDate(time) {
    return time.getTime() < new Date(new Date().toLocaleDateString()).getTime()
  }
}
